const mongoose = require('mongoose');

mongoose.connect('mongodb://127.0.0.1:27017/data');

mongoose.connection.on('error',err=>console.error(err));

mongoose.connection.once('open',()=>{
    console.log('数据库链接成功');
})

const userSchema = new mongoose.Schema({
    name:String,
    age:Number
})

const userModel = mongoose.model('users',userSchema);

module.exports = userModel;